class LoginModel {
  int code;
  LoginInfo data;
  String msg;

  LoginModel({this.code, this.data, this.msg});

  bool success() {
    return this.msg == 'SUCCESS' || this.msg == 'success';
  }

  LoginModel.fromJson(Map<String, dynamic> json) {
    code = json['code'];
    if (null != json['data']) {
      data = LoginInfo.fromJson(json['data']);
    }
    if (json['msg'] == "User entered password is wrong") {
      msg = "输入的密码有误";
    } else if (json['msg'] == "The system does not have this user") {
      msg = "该手机号尚未注册";
    } else {
      msg = json['msg'];
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['code'] = this.code;
    if (this.data != null) {
      data['data'] = this.data;
    }
    data['msg'] = this.msg;
    return data;
  }
}

class Login {
  String name;
  String pass;
  String random;
  String qut = "mobile";
  int type;

  Login({this.name, this.pass, this.random, this.type = 1});

  Login.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    pass = json['pass'];
    random = json['random'];
    qut = json['qut'];
    type = json['type'];
  }

  @override
  String toString() {
    return '{name: $name, pass: $pass, random: $random, qut: $qut, type: $type}';
  }

  Map<String, Login> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['pass'] = this.pass;
    data['random'] = this.random;
    data['qut'] = this.qut;
    data['type'] = this.type;
    return data;
  }
}

class LoginInfo {
  TokenInfo tokenInfo;
  EnterpriseInfo enterpriseInfo;
  User user;

  LoginInfo.fromJson(Map<String, dynamic> json) {
    tokenInfo = TokenInfo.fromJson(json['tokenInfo']);
    user = User.fromJson(json['user']);
    enterpriseInfo = EnterpriseInfo.fromJson(json['enterpriseInfo']);
  }
}

class EnterpriseInfo {
  String id;
  int code;
  String name;

  EnterpriseInfo.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    code = json['code'];
    name = json['name'];
  }
}

class User {
  String id;
  String mobile;
  String nick;
  int inDate;

  User.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    mobile = json['mobile'];
    nick = json['nick'];
    inDate = json['inDate'];
  }
}

class TokenInfo {
  String token;
  bool dingTalkUser;

  TokenInfo.fromJson(Map<String, dynamic> json) {
    token = json['token'];
    dingTalkUser = json['dingTalkUser'];
  }
}

// {
// data: {
// user: {
// id: "7115b51118314ba3a60e82588b8a1b01",
// name: null,
// nick: "高杰",
// pass: "77337603896b5757f304f5cc7666d88a",
// shopId: null,
// enterpriseId: "f982b9387bc74aa482a9705d8587db8a",
// avatar: null,
// email: null,
// mobile: "18682192140",
// type: 1,
// status: 1,
// dingTalkUnionId: null,
// remark: null,
// inDate: 1634884286934,
// inUser: null,
// lastEditDate: null,
// lastEditUser: null,
// createType: null,
// commonTags: null,
// mobileChecked: null,
// hardwareId: null,
// deviceType: null,
// isSmartDevice: 1,
// isShareScreen: 1,
// mac: null,
// address: null,
// assetCode: null,
// screenDirection: null,
// screenSize: null,
// screenResolution: null,
// manage: null,
// managePhone: null,
// screenGroup: null,
// screenIndex: null,
// userEnterpriseOrg: null,
// ownOrgData: false,
// ownShopData: false
// }
// shop: null,
// enterpriseInfo: {
// _id: null,
// id: "f982b9387bc74aa482a9705d8587db8a",
// code: 1161,
// name: "健康APP联调企业",
// address: "",
// business: null,
// legalRepresentative: "",
// email: "",
// telephone: "",
// homepage: "",
// desc: "",
// logo: null,
// status: 1,
// prototype: "d3bed0901168495d8198f3f5c9bf781e",
// marketCode: "",
// spId: null,
// type: 1,
// subType: 0,
// inDate: 1629968898234,
// inUser: "5daa2534d987469896ddbf83a05708ef",
// lastEditDate: 1629968898234,
// lastEditUser: "5daa2534d987469896ddbf83a05708ef",
// dingTalkCorpId: null,
// authMode: 1,
// onlinePay: 1,
// registerIp: null,
// registerIpAddr: null,
// serviceUserId: "",
// useragent: null,
// commonTags: null,
// org: null,
// adminEnterprise: false,
// prototypeEnterprise: false,
// normalEnterprise: true,
// providersAdminEnterprise: false
// }
// tokenInfo: {
// token: "357d558f948f4723a12347290a2803fd",
// dingTalkUser: false
// }
// }
// }
